package com.song.testframerk.controller;

import com.song.starter.StarterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author SONGXIAOHUI
 */
@Controller
@RequestMapping(value = "/test")
public class TestController {

    @Autowired
    private StarterService starterService ;

    @GetMapping(value = "/list.html")
    public String test(Model model){
        List<Article> list = new ArrayList<>();
        list.add(new Article("1","宋迎辉",18));
        list.add(new Article("2","lisi",20));
        list.add(new Article("3","zhangsan",22));
        model.addAttribute("list",list);
        return "test";
    }

    @GetMapping(value = "/data")
    @ResponseBody
    public String[] test2(){
        return starterService.split(",");
    }

}
